using System;
using System.Text;
using Sedna.Core.Controller.Configurations;

namespace Sedna.Core.Controls.Support.Javascript
{
	public class ScriptObject: IScriptObjectGenerator
	{
		private string className;
		private object[] parameters;

		public ScriptObject(string className, params object[] parameters)
		{
			this.className = className;
			this.parameters = parameters;
		}

		public string ToScript()
		{
			StringBuilder paramStr=new StringBuilder(250);
			foreach (object param in parameters)
			{
				paramStr.Append(new ScriptObjectGenerator(param).ToScript()+",");
			}
			paramStr.Remove(paramStr.Length-1, 1);
			return String.Format("new {0}({1})", className, paramStr.ToString());
		}

		public override string ToString()
		{
			return ToScript();
		}
	}
}
